/* 
* Class name: StartApp *
* 
* Version info: v4.0 *
* 
* Desrciption: This class is for starting the game as an application
* 
* Copyright by Group4 from CmpE450 course *
*/ 

package com.GameSpace.SameGame;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import com.GameSpace.CoreAssets.GameManager;
import com.GameSpace.SameGame.R;

public class StartApp extends Activity {
	
	//splash screen time
	long splashTime=3000;
	boolean paused=false;
	boolean active=true;
	Button gotoEnd;
	
	//keeps the level of the user
	boolean hasLevel = true;

	  @Override
	    public void onCreate( Bundle savedInstanceState ){
		  super.onCreate(savedInstanceState);
	      setContentView(R.layout.splash);
	      
	      //create a new thread to keep the splash image on the screen
		  Thread splashTimer = new Thread()
	        {
	        	public void run()
	        	{
	        		try
	        		{
	        			long ms=0;
	        			while(active && ms < splashTime)
	        			{
	        				sleep(100);
	        				if(!paused)
	        				{
	        					ms += 100;
	        				}
	        			}
	        			Init();
	        		}
	        		catch(Exception e)
	        		{
	        			Log.e("splash",e.toString());
	        		}
	        		finally
	        		{
	        			finish();
	        		}
	        	 }
	        };
	        splashTimer.start();
		}
	
	  //initializes the properties of the game
	public void Init(){
		//setting if game will have level
		GameManager.setHasLevel(hasLevel); 
		Intent StartGameIntent;
		//calls game space class
		StartGameIntent = new Intent(StartApp.this, GameSpace.class);
		startActivity(StartGameIntent);
	}
}
